5.3.3 APPX Application Design Manual

+ Chapter 1-1: Overview of Application Design
+ Chapter 1-2: Getting Started
+ Chapter 1-3: Data Dictionary
+ Chapter 1-4: Understanding Process Design
+ Chapter 1-5: Interprocess Communication
+ Chapter 1-6: Customizing Your Application
+ Chapter 1-7: The Documentation Facility
+ Chapter 1-8: Application Design Tools
+ Chapter 2-1: Data Dictionary Overview
+ Chapter 2-2: Data Dictionary Concepts
+ Chapter 2-3: Domains
+ Chapter 2-4: Files and Fields
+ Chapter 2-5: Work Fields
+ Chapter 3-1: Overview of APPX Processes
+ Chapter 3-2: Getting Started
+ Chapter 3-3: Process Definition
+ Chapter 3-4: Menu Processes
+ Chapter 3-5: Job Processes
+ Chapter 3-6: Input Processes
+ Chapter 3-7: Output Processes
+ Chapter 3-8: Update Processes
+ Chapter 3-9: Query Processes
+ Chapter 3-10: Inquiry Processes
+ Chapter 3-11: Status Processes
+ Chapter 3-12: Subroutine Processes
+ Chapter 3-13: Table Processes
+ Chapter 3-14: Automatic and Optional Children
+ Chapter 3-15: Using the Image Editor
+ Chapter 3-16: Using GUI Features of the Image Editor
+ Chapter 3-17: Using Event Points
+ Chapter 4-1: ILF Integration
+ Chapter 4-2: True/False Status Indicators
+ Chapter 4-3: Specifying Statements
+ Chapter 4-4: The ILF Editor
+ Chapter 4-5: The Appx ILF Debugger
+ Chapter 4-6: ILF Keyword Reference
+ Chapter 4-7: Predefined Fields
- Chapter 4-8: Runtime Subroutine's and Predefined Processes
+ Chapter 4-9: Appx Chart Director API

Chapter 4-8: Runtime Subroutine's and Predefined Processes

.STREAM OPEN


This subroutine is called to open a file stream.

Usage:

Description:

This subroutine is called to open a file stream. A file stream can point to an actual file on the filesystem, or it can be output from an O/S command (eg, opening a 'pipe' via a file name of "|dir" or "|ls- l"), or it can be a URL (eg, http://www.appx.com).

The first three parameters are required, and the subroutine will CANCEL if they are are not all received. The <line_termination> parameter is optional.

<stream_name> is the symbolic name of the stream used to open the file (Required). This can be any name you desire. All subsequent operations on this stream will be via this name.

<pathname> is the actual file to be opened (ie, /tmp/appx-registration.txt), the pipe to be read (ie, "|ls -l /tmp") or the URL to be read (ie, http://www.appx.com) (Required). If you are opening a file for WRITE or APPEND, Appx will also create the path if necessary.

<open_mode> determines how the file will be opened. Valid values are READ, WRITE, and APPEND. You may also just use the first letter of each word (R, W, A).

<line_termination> determines how each line will be terminated. Valid values are LF, CR/LF or NONE. This parameter is optional, and if not specified will default to CR/LF for Windows based servers and LF for all other servers. These characters will be added to the end of every line when you write it, or removed from every line when you read it.

You can open more than one stream file at at time, so long as the <stream_name> is different. Once opened, a stream file stays open until either it is explicitly closed via .STREAM CLOSE or .STREAM CLOSE ALL or your session ends.

This command is run by the appx engine, not by 'shelling out' to the O/S level, therefore the file will have the permissions of the engine (if you are creating a file) or must be readable by the engine (if you are reading a file). On Linux/Unix systems, if the 'setuid' bit is set, then the permissions will be those of user 'appx'. If you do not have the 'setuid' bit set, then the permissions will be those of whatever user you have the engine configured to impersonate. On Windows the permissions will be those of the current user.

There are 3 special file names: STDIN:, STDOUT: and STDERR:. These allow you to pipe data into an Appx session or pipe data out, or both. For example, you could write a subroutine that opens STDIN: for reading and STDOUT: for writing. You can then pipe data to a command that starts appx and runs this subroutine:

date | appx -a=<your application id> -d=<your database id> -t=SUBR -p="NAME_OF_YOUR_SUBROUTINE"

Your subroutine will then be able to read the output from the 'date' command. If your subroutine opened STDOUT: and wrote data to it, you could pipe the output from appx to another command:

appx -a=<your application id> -d=<your database id> -t=SUBR -p="NAME_OF_YOUR_SUBROUTINE" -s | more

Note the use of -s on the command line. This prevents Appx from outputting special terminal control characters to STDOUT:

Application Design Manual                                         "Powered by Appx Software"

1262

©2006 By APPX Software, Inc. All Rights Reserved